<html>
  <head>
  
	<script type="text/javascript">
	
		//JS没有变量类型 所有变量均用var定义  给var赋什么类型的值var就是什么类型
		
		//document.write("hello world");//向网页输出hello world
		
		function select_all()//函数定义 不用定义返回值类型
		{
			var all_checkbox = document.getElementsByName("all_checkbox");	//创建一个变量
			var checkboxs = document.getElementsByName("checkbox");
			
			if(all_checkbox[0].checked == true)
			{
				for(var i=0; i<checkboxs.length; i++)
				{
					checkboxs[i].checked = true;
				}
			}
			else
			{
				for(var i=0; i<checkboxs.length; i++)
				{
					checkboxs[i].checked = false;
				}
			}
		}
	
	</script>
	
  </head>
  
  <body>
  		<!-- JS语言是基于事件的   大概就是java的监听了吧 -->
    全选<input type = "checkbox" onclick="select_all()" name = "all_checkbox"><br> 
    <input type = "checkbox" name = "checkbox"><br>
    <input type = "checkbox" name = "checkbox"><br>
    <input type = "checkbox" name = "checkbox"><br>
    <input type = "checkbox" name = "checkbox"><br>
    <input type = "checkbox" name = "checkbox"><br>
    <input type = "checkbox" name = "checkbox"><br>
    
  </body>
</html>